package com.biz.primus.ms.oms.api;

import com.biz.primus.base.vo.PageResult;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.oms.vo.*;
import com.biz.primus.model.oms.vo.returns.*;
import com.biz.primus.ms.oms.service.core.OrderInterceptService;
import com.biz.primus.ms.oms.service.core.OrderQueryService;
import com.biz.primus.ms.oms.service.core.OrderStateService;
import com.biz.primus.ms.oms.service.dispatching.OrderDispatchingService;
import com.biz.primus.ms.oms.service.returns.OrderReturnQueryService;
import com.biz.primus.ms.oms.service.returns.OrderReturnStateService;
import com.biz.primus.ms.oms.service.split.OrderSplitService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yanweijin
 * @date 2017/10/31
 */
@RestController
@RequestMapping("soa/managementAllocation")
public class OmsManagementController {

	@Autowired
	private OrderQueryService orderQueryService;

	@Autowired
	private OrderSplitService orderSplitService;

	@Autowired
	private OrderStateService orderStateService;



	@Autowired
	private OrderDispatchingService orderDispatchingService;
	@PostMapping("managementOrderQuery")
	@ApiOperation("后台订单列表分页查询")
	public PageResult<OmsOrderVo> managementOrderQuery(@RequestBody  OrderQueryVo orderQueryVo){
		return orderQueryService.managementOrderQuery(orderQueryVo);
	}

	@GetMapping("getOrderDetail")
	@ApiOperation("后台获取订单详情信息")
	public OmsOrderRespVo getOrderDetail(@ApiParam(value = "订单编码", required = true) @RequestParam("orderCode")
													 String orderCode){
		return orderQueryService.getOrderDetail(orderCode);
	}


	@PostMapping("dispatching")
	@ApiOperation("改派")
	public void  dispatching(@RequestBody  OrderDispatchingRequest orderDispatchingRequest){
		orderDispatchingService.dispatching(orderDispatchingRequest);
	}

	@PostMapping("changeConsigneeInfo")
	@ApiOperation("修改收货信息")
	public void changeConsigneeInfo(@RequestBody  ChangeShippingInfoRequest changeShippingInfoRequest){
		orderStateService.changeConsigneeInfo(changeShippingInfoRequest);
	}


	@PostMapping("orderSplit")
	@ApiOperation("拆单")
	public void orderSplit(@RequestBody SplitRequestVo splitRequestVo){
		 orderSplitService.splitOrder(splitRequestVo);
	}

	@PostMapping("closeOrder")
	@ApiOperation("客服取消订单")
	public void  closeOrder(@RequestBody OrderCloseRequest orderCloseRequest){
		orderStateService.closeOrder(orderCloseRequest);
	}
}
